package net.lijingye.education.vo;

import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.SerializerFeature;
import net.lijingye.education.entity.Topic;
import net.lijingye.education.entity.TopicReply;
import net.lijingye.education.util.CommonUtil;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by LijingYe on 2016/3/26.
 */
public class TopicReplyVO {
    @JSONField(name = "id", ordinal = 0, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String id;
    @JSONField(name = "time", ordinal = 1, serialzeFeatures = SerializerFeature.WriteMapNullValue, format = "yyyy/MM/dd HH:mm")
    private Date time;
    @JSONField(name = "userId", ordinal = 2, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String userId;
    @JSONField(name = "userName", ordinal = 3, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String userName;
    @JSONField(name = "userFaceIcon", ordinal = 4, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String userFaceIcon;
    @JSONField(name = "toUserId", ordinal = 5, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String toUserId;
    @JSONField(name = "toUserName", ordinal = 6, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String toUserName;
    @JSONField(name = "toUserFaceIcon", ordinal = 7, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String toUserFaceIcon;
    @JSONField(name = "content", ordinal = 8, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String content;
    @JSONField(name = "file", ordinal = 9, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private List<String> file;

    public TopicReplyVO(TopicReply topicReply) {
        this.id = String.valueOf(topicReply.getId());
        this.time = topicReply.getTime();
        this.userId = topicReply.getAuthor().getId();
        this.userName = CommonUtil.getUserDisplayName(topicReply.getAuthor());
        this.userFaceIcon = topicReply.getAuthor().getFaceIcon();
        this.toUserId = topicReply.getToUser().getId();
        this.toUserName = CommonUtil.getUserDisplayName(topicReply.getToUser());
        this.toUserFaceIcon = topicReply.getToUser().getFaceIcon();
        this.content = topicReply.getContent();
        this.file = new ArrayList<>();
        topicReply.getTopicReplyFileList().forEach(topicReplyFile -> {
            file.add(topicReplyFile.getPath());
        });
    }

    public TopicReplyVO(String id, Date time, String userId, String userName, String userFaceIcon, String toUserId, String toUserName, String toUserFaceIcon, String content, List<String> file) {
        this.id = id;
        this.time = time;
        this.userId = userId;
        this.userName = userName;
        this.userFaceIcon = userFaceIcon;
        this.toUserId = toUserId;
        this.toUserName = toUserName;
        this.toUserFaceIcon = toUserFaceIcon;
        this.content = content;
        this.file = file;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserFaceIcon() {
        return userFaceIcon;
    }

    public void setUserFaceIcon(String userFaceIcon) {
        this.userFaceIcon = userFaceIcon;
    }

    public String getToUserId() {
        return toUserId;
    }

    public void setToUserId(String toUserId) {
        this.toUserId = toUserId;
    }

    public String getToUserName() {
        return toUserName;
    }

    public void setToUserName(String toUserName) {
        this.toUserName = toUserName;
    }

    public String getToUserFaceIcon() {
        return toUserFaceIcon;
    }

    public void setToUserFaceIcon(String toUserFaceIcon) {
        this.toUserFaceIcon = toUserFaceIcon;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public List<String> getFile() {
        return file;
    }

    public void setFile(List<String> file) {
        this.file = file;
    }

    @Override
    public String toString() {
        return "TopicReplyVO{" +
                "id='" + id + '\'' +
                ", time=" + time +
                ", userId='" + userId + '\'' +
                ", userName='" + userName + '\'' +
                ", userFaceIcon='" + userFaceIcon + '\'' +
                ", toUserId='" + toUserId + '\'' +
                ", toUserName='" + toUserName + '\'' +
                ", toUserFaceIcon='" + toUserFaceIcon + '\'' +
                ", content='" + content + '\'' +
                ", file=" + file +
                '}';
    }
}
